package org.qphoto;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.widget.ImageView;
import android.util.AttributeSet;

public class BorderImageView extends ImageView {

	public final static String namespace = "imageborder";
	int borderColor = 0;
	
	public BorderImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	
		borderColor = Color.parseColor(
				attrs.getAttributeValue(namespace,
						"BorderColor"));
	}
	
	
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub

		super.onDraw(canvas);

		Rect rec = canvas.getClipBounds();
		rec.bottom--;
		rec.right--;
		Paint paint = new Paint();
		paint.setColor(borderColor);
		paint.setStyle(Paint.Style.STROKE);
		canvas.drawRect(rec, paint);
		paint = null;
	}

}
